package com.server.http.handler.impl;

import com.server.conditionenum.HttpReturnStatus;
import com.server.db.DataBaseManager;
import com.server.http.handler.HttpHandler;
import com.server.http.request.HttpRequestMessage;
import com.server.http.response.HttpResponseMessage;
import com.server.mine.net.HttpProtocol;
import com.server.tools.AppData;

/**
* @author	李小布
* @email	397554852@qq.com
* @version	创建时间：2018年9月26日 上午11:11:04
*/
public class GetAppSwitchList extends HttpHandler{

	@Override
	public void handle(HttpRequestMessage request, HttpResponseMessage response) {
		String json = null;
		int power = 0;
		int uid = 0;
		try {
			power = Integer.parseInt(request.getParameter("power"));
			if(power >= 8) {
				json = AppData.SwitchToArray();
			}else {
				uid = Integer.parseInt(request.getParameter("uid"));
				json = DataBaseManager.GetInstance().GetAppSwitchList(uid);
			}
		}catch (Exception e) {
			e.printStackTrace();
		}
		if(json != null) {
			SetReturnData(response,json,HttpProtocol.GETSWICTHLIST,HttpReturnStatus.Successed);
		}else {
			SetReturnData(response,"获取应用列表失败!",HttpProtocol.GETSWICTHLIST,HttpReturnStatus.Successed);
		}
	}
}